#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<pthread.h>
#include<malloc.h>

void *start(void *arg)
{
	int *status;
	status = (int *)malloc(1);
	*status = 99;
	printf("second start!\n");
	sleep(1);
	printf("second end!\n");
	pthread_exit((int *)status);
}

int main()
{
	pthread_t tid;
	int ret;
	void *status;
	ret = pthread_create(&tid,NULL,start,NULL);
	if(ret)
	{
		printf("error!\n");
		exit(-1);
	}

	printf("main end!\n");
	pthread_join(tid,&status);
	printf("return value is %d\n",*((int *)status));
	//pthread_exit(NULL);
	exit(0);
}
